﻿document.write('<script language="javascript" src= "/HtmlCss/BaseJavaScript.js"></script>');

function showHuoQing(timeout, fhdwid, authority) {
    setInterval(function () {
        getHuoQing(1, fhdwid, authority);
    }, timeout * 1000); // 每隔毫秒执行一次
}

function getHuoQing(ztid, fhdwid, authority) {

    $.ajax({
        url: '/ashxs/getHuoQingByZhuangTaiId.ashx',
        type: 'GET',
        data: {
            "ztid": ztid,
            "fhdwid": fhdwid,
            "authority": authority
        },
        success: function (data) {
            var hq = JSON.parse(data);
            var myaudio = new Audio("Images/Warning.mp3");
            var banners = document.getElementById("mapDiv");
            if (hq == undefined || hq == "" || hq == null) {
                $("div.HQ_WarningDiv").remove();
                myaudio.pause();
            } else {
                $("div.HQ_WarningDiv").remove();
                //显示图片
                for (var i = 0; i < hq.length; i++) {
                    var hq_div = document.createElement("div");
                    hq_div.id = hq[i].Id;
                    hq_div.className = "HQ_WarningDiv";
                    hq_div.innerHTML = showHuoQingDiv(hq[i]);
                    banners.appendChild(hq_div);
                }
                //跳转到火情地理位置
                var lon = hq[0].Shape.X;
                var lat = hq[0].Shape.Y;
                console.log(lon + "===" + lat)
                //显示信息
                //$("#viewDiv").html(hqxx);
                //播放声音
                //myaudio.play();
            }
            console.log(hq);
        },
        error: function (jqXHR, textStatus, errorThrown) {
            console.error('Error:', textStatus, errorThrown);
        }
    });
}



function showHuoQingDiv(hq) {
    return '<div class="HQ_WarningDiv_inner">' +
        '<div align="right"><a href=JavaScript:; onClick="Lock_CheckForm(' + hq.Shape.X + ',' + hq.Shape.Y + ',' + window.level + ',' + hq.Id + '); ">[处置]</a></div > ' +
        '<div style="align:center;"><img src="Images/huoqing.png" height=210px></div>' +
        '<div>火情信息：<br>' +
        '<table>' +
        '<tr><td>所属镇街：</td><td>' + hq.FangHuoDanWei.MingCheng + '</td><td>上报时间：</td><td>' + hq.HuoQingShiJian.split('T')[0] + ' ' + hq.HuoQingShiJian.split('T')[1] + '</td></tr>' +
        '<tr><td>火情地点：</td><td>' + hq.HuoQingWeiZhi + '</td><td>地理坐标：</td><td>' + showLonLat(hq.Shape.X, hq.Shape.Y) + '</td></tr>' +
        '<tr><td>报 送 人：</td><td>' + hq.SheBei.ShiYongRen + '</td><td>联系方式：</td><td>' + hq.SheBei.LianXiFangShi + '</td></tr>' +
        '<tr><td>火情类别：</td><td>' + hq.HuoQingLeiBie.LeiBie + '</td><td>着火植被：</td><td>' + hq.HuoQingZhiBei.ZhiBei + '</td></tr>' +
        '</table></div> ';
}


function Lock_CheckForm(x, y, level,hqid) {
    $("div.HQ_WarningDiv").remove();
    jump_location(x, y, level);
    //更改火情状态为》处置中
    $.ajax({
        type: 'POST',
        url: '/Ashxs/UpdateHuoQingZhuangTai.ashx',
        data: {
            "ztid": 2,
            "hqid": hqid
        },
        success: function (data) {
            if (data == 1) {
                console.log("状态更改成功！");
                //画火情图标

                //更改其他信息
            }
        },
        timeout: 2000,
        error: function (jqXHR, textStatus) {
            console.log("请求失败，请稍后重试!");
        }
    });
}